import { http } from '@/utils/http.ts'
import type { AddressItem, AddressParams } from '@/types/address'

// 新增地址
export const memberAddressApi = (data: AddressParams) => {
  return http({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

// 获取地址列表
export const getAddressListApi = () => {
  return http<AddressItem[]>({
    url: '/member/address',
    method: 'GET',
  })
}

// 通过id 获取地址详情
export const getAddressDetailApi = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET',
  })
}


// 修改地址
export const updateAddressApi = (id: string, data: AddressParams) => {
  return http({
    url: `/member/address/${id}`,
    method: 'PUT',
    data,
  })
}

// 删除地址
export const deleteAddressApi = (id: string) => {
  return http({
    url: `/member/address/${id}`,
    method: 'DELETE',
  })
}
